package com.gilgamesh.mall.product.dao;

import com.gilgamesh.mall.product.sql.OutofstockSql;
import com.gilgamesh.mall.sdk.bean.product.OutofstockEntity;
import com.gilgamesh.mall.sdk.dto.product.OutofstockDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * Created by Peiyao.Wang on 2021/1/13
 *
 * @author Peiyao.Wang
 * @date 2021/1/13
 */
@Mapper
public interface OutofstockDao {
    @Results(
            id = "outofstockDTOMap",value = {
            @Result(column = "id" ,jdbcType = JdbcType.BIGINT,javaType = Long.class,property = "id"),
            @Result(column = "sku_code",jdbcType = JdbcType.VARCHAR,javaType = String.class,property = "skuCode"),
            @Result(column = "create_time",jdbcType = JdbcType.DATETIMEOFFSET,javaType = java.util.Date.class,property = "createTime"),
            @Result(column = "status",jdbcType = JdbcType.TINYINT,javaType =java.lang.Integer.class,property = "status"),
    }
    )


    @SelectProvider(type = OutofstockSql.class , method = "listOutofstocks")
    List<OutofstockDTO> listOutofstocks(OutofstockEntity outofstockEntity);

    @Select("select * from t_outofstock where id =#{id}")
    OutofstockDTO getOutofstockById(Long id);

}
